//
//  ShopInfoViewController.m
//  YiBaoStore
//
//  Created by 吕清毅 on 2018/11/25.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "ShopInfoViewController.h"
#import "ShopEditViewController.h"
#import "RealNameInfoViewController.h"
#import "BankInfoViewController.h"

@interface ShopInfoViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation ShopInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.dataArray = [NSMutableArray array];
    [self setNaviWith:@"店铺信息"];
    NSArray *array = @[@"店铺基本资料",@"实名信息",@"银行账户信息"];
    [self.dataArray addObjectsFromArray:array];
    [self setUpTableView];
}


- (void)setUpTableView
{
    UIView *lineView = [UIView new];
    if (@available(iOS 11.0, *)) {
        lineView.frame = CGRectMake(0, TopBarHeight_xs, SCREENWIDTH, 10);
    } else {
        // Fallback on earlier versions
        lineView.frame = CGRectMake(0, TopBarHeight, SCREENWIDTH, 10);
    }
    lineView.backgroundColor = HexWithAlpha(0xF0F0F0, 0.53);
    [self.view addSubview:lineView];
    
    if (self.tableView == nil) {
        if (@available(iOS 11.0, *)) {
            self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, lineView.bottom, SCREENWIDTH, SCREENHEIGHT-lineView.bottom) style:UITableViewStylePlain];
        } else {
            // Fallback on earlier versions
            self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, lineView.bottom, SCREENWIDTH, SCREENHEIGHT-lineView.bottom) style:UITableViewStylePlain];
        }
        self.tableView.backgroundColor = UIColorFromHex(0xF7F7F7);
        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        self.tableView.rowHeight = 57;
        self.tableView.estimatedRowHeight = 0;
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
        [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        self.tableView.tableFooterView = [UIView new];
        [TTKUtil setAutomaticallyAdjustsScrollViewInsetsWidth:self.tableView withView:self];
        [self.view addSubview:self.tableView];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"UITableViewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = self.dataArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
            {
                ShopEditViewController *shopEditVC = [ShopEditViewController new];
                [self.navigationController pushViewController:shopEditVC animated:YES];
                 break;
            }
        case 1:
        {
            RealNameInfoViewController *realNameVC = [RealNameInfoViewController new];
            [self.navigationController pushViewController:realNameVC animated:YES];
            break;
        }
        case 2:
        {
            BankInfoViewController *bankIV = [BankInfoViewController new];
            [self.navigationController pushViewController:bankIV animated:YES];
            break;
        }
        default:
            break;
    }
}
@end
